package com.doitedu.day04.funcs
import scala.collection.immutable

/**
 * @Date 22.6.23
 * @Created by HANGGE
 * @Description
 * 拉链
 *
 */
object _08Zip {
  def main(args: Array[String]): Unit = {
    val names = List[String]("wenkai" , "zhanqian" , "yifu" , "yuge" , "taoge")
    val ages  = Array[Int](18,19,20,42)
    val scores  = Array[Int](88,99,100,42)
    // 两个集合对应位置的元素 组装成对偶元组
    // 两个集合的元素的个数可以不对称  多余的元素丢失
    val tuples: immutable.Seq[(String, Int)] = names.zip(ages)
    tuples.foreach(println)
  println("---------------")
    val res: immutable.Seq[((String, Int), Int)] =  names.zip(ages).zip(scores)
    res.foreach(println)
    //  ((zhanqian,19),99)       (zhanqian,99 ,19)
    for (elem <- res)  {
      val name = elem._1._1
      val age = elem._1._2
      val score = elem._2
      println((elem._1._1,elem._1._2,elem._2))
    }
    res.foreach(tp=>{
      println((tp._1._1 , tp._1._2 ,tp._2))
    })

    res.map(tp=>{
     (tp._1._1 , tp._1._2 ,tp._2)
    })

     res.map(e=>{
       (e._1._1, e._2, e._1._2)
     })



  }

}
